﻿<?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping
  xmlns="urn:nhibernate-mapping-2.2"
  namespace="MoroMoro.Samples.ToDoList.Domain.ToDos"
  assembly="MoroMoro.Samples.ToDoList.Domain"
  default-lazy="false">

    <class name="ToDo" table="ToDos" dynamic-update="true" optimistic-lock="all">
        <id name="PrimaryKey" column="ToDoPrimaryKey">
            <generator class="guid.comb" />
        </id>
        <property name="Title" not-null="true" length="100" unique="true" index="true" />
        <many-to-one name="Category" column="CategoryPrimaryKey" foreign-key="Category_ToDos" cascade="none" index="true" />
        <list name="Memos" lazy="true" cascade="all-delete-orphan" optimistic-lock="true">
            <key column="ToDoPrimaryKey" foreign-key="ToDo_Memos" not-null="false" />
            <list-index column="OrderIndex" />
            <one-to-many class="Memo" />
        </list>
        <property name="RegisteredDateTime" not-null="true" index="true" />
        <property name="TouchedDateTime" not-null="false" index="true" />
        <property name="CompletedDateTime" not-null="false" index="true" />
    </class>

    <class name="Memo" table="Memos" dynamic-update="true" optimistic-lock="all">
        <id name="PrimaryKey" column="MemoPrimaryKey">
            <generator class="guid.comb" />
        </id>
        <property name="Text" not-null="true" length="1000" />
    </class>

</hibernate-mapping>